package me.shiqiang.im.statistics;

import java.util.concurrent.atomic.AtomicLong;

/**
 * Created by John on 2018/1/29
 */
public class LoginCount {
    private static LoginCount instance = new LoginCount();

    private LoginCount(){}

    public static LoginCount getInstance() {
        return instance;
    }

    private AtomicLong loginCount = new AtomicLong(0);
    private long maxCount = 0L;

    public long increment() {
        long count = loginCount.incrementAndGet();
        maxCount = count > maxCount ? count : maxCount;
        return count;
    }

    public long decrement() {
        return loginCount.decrementAndGet();
    }

    public long getCount() {
        return loginCount.get();
    }

    public long getMaxCount(){
        return maxCount;
    }
}
